﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework;

namespace projekt_planet_express_doerr
{
    class SkyBox
    {
        private Model skyBox;
        private TextureCube skyBoxTexture;
        private Effect skyBoxEffect;
        private float size = 50f;

        public SkyBox(string EmptySpace, ContentManager Content)
        {
            skyBox = Content.Load<Model>("cube");
            skyBoxTexture = Content.Load<TextureCube>(EmptySpace);
            skyBoxEffect = Content.Load<Effect>("Skybox");
        }

        public void drawSkybox(Matrix world, Matrix view, Matrix projection)
        {
            foreach (EffectPass pass in skyBoxEffect.CurrentTechnique.Passes)
            {
                foreach (ModelMesh mesh in skyBox.Meshes)
                {
                    foreach (ModelMeshPart part in mesh.MeshParts)
                    {
                        part.Effect = skyBoxEffect;
                        part.Effect.Parameters["World"].SetValue(world * Matrix.CreateScale(size));
                        part.Effect.Parameters["View"].SetValue(view);
                        part.Effect.Parameters["Projection"].SetValue(projection);
                        part.Effect.Parameters["SkyBoxTexture"].SetValue(skyBoxTexture);
                    }
                    mesh.Draw();
                }
            }
        }
    }
}
